package DemoReview;

/**
 * 寻找数组的中心下标
 *
 *
 */
public class LeetCode724 {
    public int pivotIndex(int[] nums) {
        int n = nums.length;
        int target = 0, sum = 0;
        for (int x : nums) target += x;
        for (int i = 0; i < n; i++) {
            sum += nums[i];
            if (target- sum == sum - nums[i]) return i;
        }
        return -1;
    }
}
